#ifndef Chart_IndexConfig_h
#define Chart_IndexConfig_h

#include "EnumDefinition.h"
#include "json.h"

#include <utility>
#include <string>
#include <vector>
#include <map>

namespace ytx
{

	class IndexConfig {
    private:
        static std::vector<std::string> arrayToVector(std::string input[], int length);
        static std::vector<double> intToVector(double input[], int length);
    protected:
        int indexPermission;
        std::string indexName;
	public:
        IndexType::IndexType indexType;
        
        IndexChartType::IndexChartType indexChartType;
        unsigned int indexChartViewType; //异或

		std::vector<std::string> type;
		std::vector<std::string> name;
		std::vector<double> value;
        std::vector<double> ratio;
		std::vector<std::pair<double, double> > range;
        bool enabled;

        bool particular;

        const std::string getIndexName();

        const YTXJson::Value toJSONValue() const;

        const std::string toJSONString() const;

        static IndexConfig createByJSONString(std::string json);

        static IndexConfig create(YTXJson::Value json);

        IndexConfig(IndexType::IndexType indexType, std::string indexName, IndexChartType::IndexChartType indexChartType, const std::vector<std::string> type, const std::vector<std::string> name, const std::vector<double> value, const std::vector<std::pair<double, double> > range, bool enabled = true, std::vector<double> ratio = std::vector<double>());

        IndexConfig(IndexType::IndexType indexType, std::string indexName, IndexChartType::IndexChartType indexChartType, unsigned int indexChartViewType, const std::vector<std::string> type, const std::vector<std::string> name, const std::vector<double> value, const std::vector<std::pair<double, double> > range, bool enabled = true, std::vector<double> ratio = std::vector<double>());

        IndexConfig(IndexType::IndexType indexType=IndexType::EMPTY);

        bool eqauls(const IndexConfig & indexConfig);

        IndexConfig extend(const IndexConfig & indexConfig);

        void extendSelf(const IndexConfig & indexConfig);

        void clearIndexPermission();

        void setIndexPermission(int indexPermission);

        bool isParticularAndHas();

        bool hasIndex();

        int getIndexPermission();

        static const std::pair<std::string, std::string> getParticularIndexImagePath(IndexType::IndexType indexType);

        static const std::map<IndexType::IndexType, IndexConfig> initIndex();

//        static const std::map<IndexType::IndexType, IndexType::IndexType> createKLineMainIndexReflect();

//        static const std::map<IndexType::IndexType, IndexType::IndexType> mainKLineIndexReflect;

//        static const IndexType::IndexType toggleKLineMainIndexType(IndexType::IndexType indexType);

//        static const std::map<IndexType::IndexType, IndexType::IndexType> createKLineMinorIndexReflect();

//        static const std::map<IndexType::IndexType, IndexType::IndexType> minorKLineIndexReflect;

        static const IndexType::IndexType toggleKLineMinorIndexType(IndexType::IndexType indexType);

        static const IndexType::IndexType getIndexTypeByString(std::string type);

        static const IndexChartType::IndexChartType getIndexChartTypeByString(std::string type);

	};
}

#endif
